<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>扩展运算符</h1>
    <script>
        var arr = [1, 2, 4, 5, ['hello', 'world']]
        // 通过扩展运算符实现数组   浅拷贝
        var arr2 = [...arr]
        // 删除拷贝数组中的第一个元素
        arr2.splice(0, 1)
        // 修改拷贝数组
        arr2[arr2.length - 1][0] = '你好'
        console.log(arr, '原始数组');

        // 通过扩展运算符实现对象   浅拷贝
        var obj = { name: "jack", age: 20, city: '北京' }
        var obj2 = { ...obj, gender: "男" }
        console.log(obj2);
    </script>
</body>

</html>